<% content_for :title do %>
  <%=h @song.title %>
<% end %>

<% content_for :edit do %>
  <%= link_to 'Delete Entry?', 
              new_delete_request_path(:editable_id => @song.id, 
                                      :editable_type => "Song") %> |

  <% if session[:edit_mode] == false %>
    <%= link_to 'Edit This Page', edit_song_path %> 
  <% else %>
    <%= link_to 'Finish Editing', song_path %> 
  <% end %>
<% end %>

<table id="entry-table">

  <tr id="entry-table-row1">
    <td id="entry-top-pane">
      <span class="entry-title">
        <%=h @song.title %>
      </span>

      <br />
      <span class="entry-title-sub">
        by: <%- @song.artists.each do |artist| -%>
              <%= link_to artist.name, artist %>
              <%= (artist != @song.artists.last)? "&" : "" %> 
            <%- end -%>
      </span>

      <div id="top-tools">
        <% if @favorite.nil? %>
          <% if permitted_to? :create, :favorites %>
            <%= link_to 'Favorite', add_favorite_path(:id => @song.id,
                                                      :type => 'Song') %>
          <% end %>
        <% else %>
          <% if permitted_to? :destroy, :favorites %>
            <%= link_to 'Remove From Favorites', remove_favorite_path(:id => @favorite) %>
          <% end %>
        <% end %>
      </div><!-- /top-tools -->

    </td><!-- /entry-top-pane -->
  </tr><!-- /entry-table-row1 -->

  <tr id="entry-table-row3">
    <td class="entry-left-pane">
      <div id="entry-left-menu">
        <ul class="tabnav">
          <%= song_tab('Info', 'info-pane', 'active') %>
          <%= song_tab('Credits', 'credit-pane', 'active') %>
          <%= song_tab('Other Versions', 'featured-pane', 'inactive') %>
          <%= song_tab('Lyrics', 'lyric-pane', 'inactive') %>
          <%= song_tab('Reviews', 'review-pane', 'inactive') %>
        </ul>
      </div><!-- /entry-left-menu -->
    </td><!-- /entry-left-pane -->

    <td class="entry-mid-pane">
      
      <div id="entry-mid-content">

        <div id="info-pane">
		  <h2>The Basics</h2>
		  
		  This is a version of the song <strong><%= @song.song_collection.name %></strong><br /><br />
	
	      <% if @song.disc %>
			Appears On: <strong><%= link_to @song.disc.edition, @song.disc.edition %></strong><br />
			Track: <%=h (@song.track.nil?) ? "" : @song.track %><br />
	      <% end %>
	      Length: <%= @song.length_in_mins %><br />
	      <br />
		
          <h3>Info</h3>
		  <div id="song-info">
		    <% if @song.info.blank? %>
		      No one has written anything about this song. Add a description by editing this page.
		    <% else %>
              <%= simple_format(@song.song_collection.info) %>
		    <% end %>
            <br />
          </div>
		  
          <div id="edit-history">
            <h3>Edit History</h3>
            <%= link_to 'Full History for This Page', song_edits_path(@song) %>
          </div><!-- /edit-history -->

        </div><!-- /info-pane -->

        <div id="credit-pane" style="display: none">
          <h3>Credits</h3>

          <% @song.song_credits.each do |credit| %>

            <div class="credit-pane-data">
              <%=h credit.role %>
              <%=h (credit.details.blank?) ? "" : " [" + credit.details + "]" %>
			  by <%= link_to credit.artist.name, credit.artist %>
              <br />
            </div><!-- /credit-pane-data -->
          <% end %>

        </div><!-- /credit-pane -->

        <div id="featured-pane" style="display :none">
          <h2>Other Versions</h2>
           
		  <table id="song-table">
		    <tr id="song-table-header">
			  <th>Name</th>
			  <th>Length</th>
			  <th>Track</th>
			  <th>Album</th>
			</tr>
			
			<% @song.versions.each do |v| %>
			  <% next if v == @song %>
			
			<tr class="song-table-version">
			  <td><%= link_to v, v %></td>
			  <td><%=h v.length_in_mins %></td>
			  <td><%= v.track %></td>
			  <td>
			  <% if v.disc %>
			    <%= link_to v.disc.edition, v.disc.edition %>
			  <% else %>
			  -
			  <% end %>
			  </td>
			</tr>
			
			<tr colspan="4">
			  <td class="song-table-credit">
			  <% v.song_credits.each do |credit| %>
			    <%=h credit.role %>
				<%=h (credit.details.blank?) ? "" : "[" + credit.details + "]" %>
				by <strong><%=h link_to credit.artist, credit.artist %></strong>
			  <% end %>
			  </td>
			</tr>
			<% end %>
		  </table>

        </div><!-- /featured-pane -->

        <div id="lyric-pane"style="display :none">
          <h2>Lyrics</h2>
		  <%= simple_format(@lyrics.lyrics) %>
		  <% if @lyrics.lyrics_found? %>
		    See the rest at <strong><%= link_to 'LyricsWikia', @lyrics.url %></strong>
		  <% else %>
		    How about going to <strong><%= link_to 'LyricsWikia', "http://lyrics.wikia.com/" %></strong> and adding these lyrics?
		  <% end %>
        </div><!-- /lyric-pane -->

        <div id="review-pane" style="display: none">
          <h2>Reviews</h2>
          <%= render :partial => 'reviews/review', :locals => {:item => @song} %>
        </div><!-- /review-pane -->

      </div><!-- /entry-mid-content -->
    </td>
  </tr>
</table>